package com.whmall.service.crm.module.companyuser.enumeration;

/**
 * 通知Bitmap下标枚举
 *
 * @author alex
 * @since 2020/8/3
 */
public enum EmailNotifyBitmapEnum {
    /**
     * 询价，询盘报价通知
     */
    INQUIRY_NOTICE(0, "询价"),
    /**
     * 报价通知，发送报价通知
     */
    QUOTATION_NOTICE(1, "报价通知"),
    /**
     * 客户订单，夜间创建完成后通知
     */
    SALE_ORDER_NOTICE(2, "客户订单"),
    /**
     * 采购订单，订单创建完成后通知
     */
    PURCHASE_ORDER_NOTICE(3, "采购订单"),
    /**
     * 发货通知，供应商发货后通知
     */
    SHIP_NOTICE(4, "发货通知"),
    /**
     * 缺货通知
     */
    OUT_OF_STOCK_NOTICE(5,"缺货通知");
    ;

    public static EmailNotifyBitmapEnum fromNullableIndex(Integer index) {
        if (null == index) {
            return null;
        }

        return fromIndex(index);
    }

    public static EmailNotifyBitmapEnum fromIndex(Integer index) {
        for (EmailNotifyBitmapEnum anEnum : values()) {
            if (anEnum.getIndex() == index) {
                return anEnum;
            }
        }

        throw new UnsupportedOperationException("不支持的通知类型");
    }

    EmailNotifyBitmapEnum(int index, String name) {
        this.index = index;
        this.name = name;
    }

    private final int index;
    private final String name;

    public int getIndex() {
        return index;
    }

    public String getName() {
        return name;
    }
}
